package com.cn.kabalifeuser.ui.my.bean;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;

import com.cn.kabalifeuser.R;
import com.cn.kabalifeuser.base.IBaseActivity;
import com.cn.kabalifeuser.config.LoginHelper;
import com.cn.kabalifeuser.ui.login.bean.MsgBean;
import com.cn.kabalifeuser.ui.my.activity.UpPhoneCodeActivity;
import com.cn.kabalifeuser.ui.my.activity.UpPhonePresenter;
import com.cn.kabalifeuser.ui.my.activity.UpPhoneView;
import com.cn.kabalifeuser.utils.RxToast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目：KaBaLifeUser
 * 包名：com.cn.kabalifeuser.ui.my.bean
 * 类名：UpPhoneActivity
 * 创建时间：2020/11/10 11:11 AM
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
public class UpPhoneActivity extends IBaseActivity<UpPhoneView, UpPhonePresenter> implements UpPhoneView {
    @BindView(R.id.et_phone)
    EditText etPhone;

    @Override
    protected UpPhonePresenter createPresenter() {
        return new UpPhonePresenter();
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_up_phone;
    }


    @Override
    public void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        setTitleBar("修改手机");
    }

    @OnClick(R.id.tv_btn_next)
    public void onViewClicked() {
        if (!TextUtils.isEmpty(etPhone.getText().toString().trim())) {

            mPresenter.onPhoneCodeData(etPhone.getText().toString().trim(), 1);


        } else RxToast.error("请输入正确时的手机号码");
    }

    @Override
    public void onPhoneCodeSuccess(MsgBean bean) {
        RxToast.success(bean.getMsg());
        Bundle bundle = new Bundle();
        bundle.putString("phone", etPhone.getText().toString().trim());
        $startActivityFinish(UpPhoneCodeActivity.class, bundle);
    }

    @Override
    public void onReLoggedIn(String msg) {

        RxToast.error(msg);
        LoginHelper.againGoToLoginActivity(getMe());
    }

    @Override
    public void onError(String msg) {
        RxToast.error(msg);
    }

    @Override
    public Context _getContext() {
        return getMe();
    }

    @Override
    public void onUpUserInfoSuccess(MsgBean bean) {

    }
}
